package com.cxcy.swustlearner.controller;

import com.cxcy.swustlearner.pojo.HomeWork;
import com.cxcy.swustlearner.service.HomeWorkService;
import common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/course")
public class HomeWorkController {
    @Autowired
    private HomeWorkService homeWorkService;
    @GetMapping()
    public Result homeWork() {
        return Result.success(homeWorkService.getHomeWork());
    }
    @PostMapping()
    public Result addHomeWork(@RequestBody HomeWork homeWork) {
        homeWorkService.insertHomeWork(homeWork);
        return Result.success("添加成功");
    }
    @PutMapping()
    public Result updateHomeWork(@RequestBody HomeWork homeWork) {
        homeWorkService.updateHomeWork(homeWork);
        return Result.success("修改成功");
    }
}
